package com.hrp.analyzer.request;

import java.net.Proxy;


/**
 * @author hrp
 * @date 2020/12/21 12:47 上午
 */

public class HttpConfig {
    /**
     * 读取超时时间
     */
    private long readTimeout = 10L;
    /**
     * 连接超时时间
     */
    private long connectionTimeout = 10L;
    /**
     * 自动重定向
     */
    private boolean followRedirect = true;
    /**
     * 连接失败时重试
     */
    private boolean retryOnFailed = true;
    /**
     * 连接池最大空闲连接
     */
    private int maxIdleConnections = 5;
    /**
     * 连接池空闲连存活时间 秒
     */
    private long keepAliveDuration = 5L;
    /**
     * 代理
     */
    private Proxy proxy = Proxy.NO_PROXY;

    /**
     * 默认配置
     *
     * @return /
     */
    public static HttpConfig defaultConfig() {
        return new HttpConfig();
    }

    public long getReadTimeout() {
        return readTimeout;
    }

    public HttpConfig setReadTimeout(long readTimeout) {
        this.readTimeout = readTimeout;
        return this;
    }

    public long getConnectionTimeout() {
        return connectionTimeout;
    }

    public HttpConfig setConnectionTimeout(long connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
        return this;
    }

    public boolean isFollowRedirect() {
        return followRedirect;
    }

    public HttpConfig setFollowRedirect(boolean followRedirect) {
        this.followRedirect = followRedirect;
        return this;
    }

    public boolean isRetryOnFailed() {
        return retryOnFailed;
    }

    public HttpConfig setRetryOnFailed(boolean retryOnFailed) {
        this.retryOnFailed = retryOnFailed;
        return this;
    }

    public int getMaxIdleConnections() {
        return maxIdleConnections;
    }

    public HttpConfig setMaxIdleConnections(int maxIdleConnections) {
        this.maxIdleConnections = maxIdleConnections;
        return this;
    }

    public long getKeepAliveDuration() {
        return keepAliveDuration;
    }

    public HttpConfig setKeepAliveDuration(long keepAliveDuration) {
        this.keepAliveDuration = keepAliveDuration;
        return this;
    }

    public Proxy getProxy() {
        return proxy;
    }

    public HttpConfig setProxy(Proxy proxy) {
        this.proxy = proxy;
        return this;
    }
}
